//
//  ViewController.m
//  07-通信传值
//
//  Created by dllo on 16/7/22.
//  Copyright © 2016年 YMJ. All rights reserved.
//

#import "ViewController.h"
// 延展也可以签订协议
@interface ViewController ()<NextViewControllerDelegate>
@property (nonatomic, strong) UILabel *label;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 100, 50);
    [button addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    button.backgroundColor = [UIColor whiteColor];
    
    self.label = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 100, 50)];
    self.label.text = @"你好";
    self.label.backgroundColor = [UIColor purpleColor];
    [self.view addSubview:self.label];
}
// 实现方法
- (void)sendValue:(NSString *)string {
  
    _label.text = string;
}
- (void)click {
    NextViewController *next = [NextViewController new];
    [self.navigationController pushViewController:next animated:YES];
    next.titleString = self.label.text;
    
    // 
    next.delegate = self;
}
- (void)viewWillAppear:(BOOL)animated {
    // 反面传值
    [super viewWillAppear:animated];
    NSLog(@"%@",_textString);
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
